package com.job.learn.cuiyt.config;

import com.dangdang.ddframe.job.lite.spring.api.SpringJobScheduler;
import com.dangdang.ddframe.job.reg.base.CoordinatorRegistryCenter;
import com.dangdang.ddframe.job.reg.zookeeper.ZookeeperConfiguration;
import com.dangdang.ddframe.job.reg.zookeeper.ZookeeperRegistryCenter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
 * @author: cuiyutian1
 * @date: 2021/12/26 13:11
 * @description:
 */
@Configuration
public class JobConfig {

    private static int PORT = 2181;
    private static String CONNECTION = "127.0.0.1:"+ PORT;
    private static String NAME_SPACE = "easy-job";


    @Bean(initMethod = "init")
    static CoordinatorRegistryCenter setUpRegister(){
        ZookeeperConfiguration configuration = new ZookeeperConfiguration(CONNECTION, NAME_SPACE);
        configuration.setSessionTimeoutMilliseconds(100);
        ZookeeperRegistryCenter center = new ZookeeperRegistryCenter(configuration);
        center.init();
        return center;
    }

}
